package com.rayo.accesscontrollercopy.model.db.dao;

import com.litesuits.orm.db.assit.QueryBuilder;
import com.rayo.accesscontrollercopy.model.db.DbHelp;
import com.rayo.accesscontrollercopy.model.db.bean.PlanKeyTempData;

import java.util.List;

/**
 * Created by yanghaojie on 16/7/27.
 */
public class PlanKeyTempImpl implements PlanKeyTempDao {
    @Override
    public void addOrUpdateKeyPlan(PlanKeyTempData keyPlanData) {

        DbHelp.insert(keyPlanData);
//        Log.d("SocketClient", "userid:" + keyPlanData.getUserid() + "插入");
    }

    @Override
    public void deletTempKeyPlanById(int keyId) {
        DbHelp.deleteWhere(PlanKeyTempData.class, PlanKeyTempData.USER_ID,
                new String[]{String.valueOf(keyId)});
    }

    @Override
    public void deleteAll() {
        DbHelp.deleteAll(PlanKeyTempData.class);
    }

    @Override
    public List<PlanKeyTempData> findPlanKeyByUserId(int userId) {
        QueryBuilder qb = new QueryBuilder(PlanKeyTempData.class).whereEquals(PlanKeyTempData.USER_ID, userId);
        return DbHelp.liteOrm.query(qb);
    }
}
